package com.java.star.mall.front.pojo.vo;

import com.java.star.mall.common.constant.data.OrderConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * 订单可进行的操作
 */
@Data
public class AllowOperationVO implements Serializable {

    private static final long serialVersionUID = -7013580957908893270L;

    @ApiModelProperty(value = "是否可以取消")
    private Boolean cancel;

    @ApiModelProperty(value = "是否可以支付")
    private Boolean pay;

    @ApiModelProperty(value = "是否可以收货")
    private Boolean rog;

    @ApiModelProperty(value = "是否允许查看物流信息")
    private Boolean showLogistics;

    @ApiModelProperty(value = "是否处于中间状态")
    private Boolean intermediateState;

    public AllowOperationVO(OrderListVO orderListVO) {
        //获取订单类型
        String status = orderListVO.getStatus();

        //是否允许取消
        this.cancel = status.equals(OrderConstant.ORDER_STATUS_CREATE_NEW)
                || status.equals(OrderConstant.ORDER_STATUS_PAYED);

        //是否允许支付
        this.pay = status.equals(OrderConstant.ORDER_STATUS_CREATE_NEW);

        //是否允许被收货
        this.rog = status.equals(OrderConstant.ORDER_STATUS_SENT);

        //是否允许查看物流信息
        this.showLogistics = status.equals(OrderConstant.ORDER_STATUS_SENT);

        //是否处于中间状态，业务上把已取消或已完成定义为非中间状态，反之则是中间状态
        this.intermediateState = status.equals(OrderConstant.ORDER_STATUS_CANCELLED)
                || status.equals(OrderConstant.ORDER_STATUS_RECEIVED);

        //TODO 后续还要增加其他情况 例如 售后，改地址等
    }
}
